Java.perform(function () {
    console.log("开始Hook PATH类...");

    try {
        let PATH = Java.use("com.zhangyue.iReader.app.PATH");
        PATH["getWorkDir"].implementation = function () {
            console.log("PATH.getWorkDir is called");
            let result = this["getWorkDir"]();
            console.log("PATH.getWorkDir result: " + result);
            return result;
        };
        console.log("PATH Hook成功");
    } catch (e) {
        console.log("PATH Hook失败: " + e);
    }

    // 同时Hook一些Context相关方法获取路径信息
    try {
        let ContextWrapper = Java.use("android.content.ContextWrapper");
        ContextWrapper["getFilesDir"].implementation = function () {
            let result = this["getFilesDir"]();
            console.log("getFilesDir: " + result.getAbsolutePath());
            return result;
        };

        ContextWrapper["getDataDir"].implementation = function () {
            let result = this["getDataDir"]();
            console.log("getDataDir: " + result.getAbsolutePath());
            return result;
        };

        ContextWrapper["getCacheDir"].implementation = function () {
            let result = this["getCacheDir"]();
            console.log("getCacheDir: " + result.getAbsolutePath());
            return result;
        };
        console.log("Context相关Hook成功");
    } catch (e) {
        console.log("Context Hook失败: " + e);
    }

});